n= int(input())
ls = list(map(int , input().split()))
dollars=ls[0]
energy = 0
for i in range (n-1):
step=ls[i]-ls[i+1]
energy +=step
if energy<0:
dollars+=-energy
energy=0
print(dollars)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define test_case int t;cin>>t;while(t--)
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define endl "\n"
/*
include <ext/pb_ds/assoc_container.hpp>
include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// less: it is the basic for comparison of two function. Use less_equal for ordered multiset.
// order_of_key(k): Number of items strictly smaller than k
// find_by_order(k): kth element in a set (counting from zero)
*/
const double pi = acos(-1.0);
const double EPS = 1e-9;
const int mod = 1e9+7;
void Fast()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int gcd(ll a, ll b)
{
return a ? gcd(b % a, a) : b;
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b) * b;
}
void solve()
{
int N;
cin>>N;
vector<int>V(N);
for (int I=0;I<N;I++)
{
cin>>V[I];
}
int E=0,cost=V[0];
for (int I=0;I<N-1;I++)
{
if (V[I]-V[I+1]<0)
{
if (E>=abs(V[I]-V[I+1]))
{
E-=abs(V[I]-V[I+1]);
}
else
{
cost+=abs(V[I]-V[I+1])-E;
E=0;
}
}
else
{
E+=V[I]-V[I+1];
}
}
cout<<cost<<endl;
}
int main()
{
//freopen("hunter.in","r",stdin);
//freopen(".out","w",stdout);
Fast();
//test_case
solve();
return 0;
}
977A - Wrong Subtraction | 263A - Beautiful Matrix |
180C - Letter | 151A - Soft Drinking |
1352A - Sum of Round Numbers | 281A - Word Capitalization |
1646A - Square Counting | 266A - Stones on the Table |
61A - Ultra-Fast Mathematician | 148A - Insomnia cure |
1650A - Deletions of Two Adjacent Letters | 1512A - Spy Detected |
282A - Bit++ | 69A - Young Physicist |
1651A - Playoff | 734A - Anton and Danik |
1300B - Assigning to Classes | 1647A - Madoka and Math Dad |
710A - King Moves | 1131A - Sea Battle |
118A - String Task | 236A - Boy or Girl |
271A - Beautiful Year | 520B - Two Buttons |
231A - Team | 479C - Exams |
1030A - In Search of an Easy Problem | 158A - Next Round |
71A - Way Too Long Words | 160A - Twins |